<template>
  <div id="myOrder">
    <el-container>
      <el-header height="80px">
        <el-row>
          <el-col :span="3" id="logo" offset="2">我的淘物</el-col>
          <el-col :span="3" id="logo" offset="4">
            <el-dropdown>
              <span class="el-dropdown-link">
                首页<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>订单中心</el-dropdown-item>
                <el-dropdown-item>我的钱包</el-dropdown-item>
                <el-dropdown-item>我的关注</el-dropdown-item>
                <el-dropdown-item>我的活动</el-dropdown-item>
                <el-dropdown-item>客户服务</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
          <el-col :span="3" id="logo">
            <el-dropdown>
              <span class="el-dropdown-link">
                账户设置<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>账户安全</el-dropdown-item>
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>收货地址</el-dropdown-item>
                <el-dropdown-item>我的银行卡</el-dropdown-item>
                <el-dropdown-item>账户绑定</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </el-col>
          <el-col :span="3" offset="5" class="search">
            <input type="text" placeholder="" class="search_text" />
            <i class="search_button">搜索</i>
          </el-col>
          <el-col :span="4">
            <el-col :span="15" class="shopping_cart">
              <el-col :span="7" class="shopping_cart_icon"
                ><img src="../../assets/images/购物车.png" alt=""
              /></el-col>
              <el-col :span="11" class="shopping_cart_text">我的购物车</el-col>
              <div class="shopping_cart_num">2</div>
            </el-col>
          </el-col>
        </el-row>
      </el-header>
    </el-container>
    <el-row>
      <el-col :span="20" id="wrapper" offset="2">
        <el-col :span="4" id="left">
          <div id="left_text">
            <div id="left_text_1">
              <div id="left_text_title">订单中心</div>
              <div id="left_text_item">我的订单</div>
              <div id="left_text_item">评价晒单</div>
            </div>
            <div id="left_text_2">
              <div id="left_text_title">我的钱包</div>
              <div id="left_text_item">优惠券</div>
              <div id="left_text_item">红包</div>
              <div id="left_text_item">礼品卡</div>
              <div id="left_text_item">更多></div>
            </div>
            <div id="left_text_3">
              <div id="left_text_title">我的关注</div>
              <div id="left_text_item">关注商品</div>
              <div id="left_text_item">关注店铺</div>
            </div>
            <div id="left_text_4">
              <div id="left_text_title">我的活动</div>
              <div id="left_text_item">我的预约</div>
              <div id="left_text_item">我的回收单</div>
              <div id="left_text_item">我的拍卖</div>
              <div id="left_text_item">我的口令</div>
              <div id="left_text_item">更多></div>
            </div>
            <div id="left_text_5">
              <div id="left_text_title">客户服务</div>
              <div id="left_text_item">返修退换货</div>
              <div id="left_text_item">价格保护</div>
              <div id="left_text_item">我的发票</div>
              <div id="left_text_item">购买咨询</div>
              <div id="left_text_item">交易纠纷</div>
              <div id="left_text_item">更多></div>
            </div>
            <div id="left_text_6">
              <div id="left_text_title">特色业务</div>
              <div id="left_text_item">我的营业厅</div>
              <div id="left_text_item">医疗服务</div>
              <div id="left_text_item">流量加油站</div>
              <div id="left_text_item">更多></div>
            </div>
          </div>
        </el-col>
        <el-col :span="20" id="right">
          <div class="right_top">我的订单</div>
          <div class="right_bottom">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane
                :label="item1.label"
                :name="item1.name"
                v-for="(item1, index1) in tab"
                :key="index1"
              >
                <center v-for="(item2, index2) in orderList" :key="index2">
                  <table border="1" class="tb colorth">
                    <tr>
                      <td class="th">{{ item2.date }}</td>
                      <td class="th">
                        订单号： <span class="black">{{ item2.OrderID }}</span>
                      </td>
                      <td class="th">
                        <span class="black"> {{ item2.shopName }}</span>
                      </td>
                    </tr>
                    <tr class="tr">
                      <td class="td img">
                        <img
                          :src="item2.goodsImg"
                          alt=""
                          width="60px"
                          height="60px"
                        />
                      </td>
                      <td class="td title black">
                        {{ item2.goodsName | ellipsis }}
                      </td>
                      <td class="td">x{{ item2.goodsCount }}</td>
                      <td class="td black">申请售后</td>
                      <td class="td black">{{ item2.username }}</td>
                      <td class="td">￥{{ item2.goodsPrice }}</td>
                      <td class="td">{{ item2.orderStatus }}</td>
                      <td class="td"><button>立即购买</button></td>
                    </tr>
                  </table>
                </center>
              </el-tab-pane>
            </el-tabs>
          </div>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getSelfOrderListAPI } from "@/api";
export default {
  name: "myOrder",
  data() {
    return {
      uid: sessionStorage.getItem("uid"),
      activeName: "first",
      orderList: [],
      tab: [
        {
          label: "全部订单",
          name: "first",
        },
      ],
    };
  },

  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 30) {
        return value.slice(0, 30) + "...";
      }
      return value;
    },
  },

  mounted() {
    this.showOrders();
  },

  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    async showOrders() {
      const id = parseInt(this.uid);
      const res = await getSelfOrderListAPI(id);
      if (res.data.statusCode === 200) {
        this.orderList = res.data.data;
        // this.porps = this.orderList
        console.log(this.orderList);
      }
    },
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
body {
  background-color: rgb(240, 243, 239);
}
#myOrder {
  background-color: rgb(240, 243, 239);
}

#wrapper {
  height: 1000px;
}

/* 左侧导航栏 */
#left {
  background-color: rgb(240, 243, 239);
}
#left_text {
  width: 80%;
  height: 100%;
  background-color: white;
}
#left_text_1,
#left_text_2,
#left_text_3,
#left_text_4,
#left_text_5,
#left_text_6 {
  border-bottom: 1px solid rgb(192, 192, 192, 0.2);
  width: 100%;
  padding: 20px 0px;
}
#left_text_title {
  margin-left: 15px;
  font-size: 17px;
  font-weight: bold;
}
#left_text_item {
  margin-top: 10px;
  margin-left: 15px;
  font-size: 15px;
}

.el-header {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  height: 80px;
  line-height: 80px;
}
#logo {
  height: 80px;
  width: 100px;
  color: #333;
  font-size: 20px;
}
.el-dropdown-link {
  color: rgb(223, 48, 40);
  height: 30px;
  line-height: 30px;
  font-size: 16px;
  text-align: center;
  cursor: default;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.search_text {
  float: left;
  height: 24px;
  line-height: 24px;
  color: #666;
  padding: 4px;
  margin-bottom: 4px;
  border-width: 2px 0 2px 2px;
  border-style: solid;
  outline: 0;
  font-size: 14px;
  width: 140px;
  border-color: #df3028;
  font-family: "microsoft yahei";
  margin-top: 20px;
}
.search_button {
  top: 20px;
  left: 140px;
  width: 62px;
  height: 36px;
  display: block;
  overflow: hidden;
  font-style: normal;
  background-color: #df3028;
  font-size: 14px;
  float: left;
  border: none;
  border-radius: 0;
  line-height: 1;
  color: #fff;
  font-family: "Microsoft YaHei";
  /* font-size: 16px; */
  cursor: pointer;
  line-height: 36px;
  position: absolute;
}
#myOrder .search {
  position: relative;
}
.shopping_cart {
  height: 36px;
  width: 210px;
  margin-left: 56px;
  margin-top: 20px;
  background-color: rgb(249, 249, 249);
  border: rgb(223, 223, 223) 1px solid;
  position: relative;
}
.shopping_cart_icon {
  height: 36px;
}
.shopping_cart_icon img {
  height: 20px;
  width: 20px;
  margin-bottom: 18px;
  margin-left: -5px;
  margin-top: 8px;
  position: absolute;
}
.shopping_cart_text {
  height: 36px;
  font-size: 13px;
  line-height: 36px;
  position: absolute;
  margin-left: 42px;
}
.shopping_cart_num {
  height: 18px;
  width: 18px;
  border-radius: 100%;
  margin-left: 120px;
  margin-top: 9px;
  background-color: red;
  font-size: 12px;
  line-height: 18px;
  color: #ffffff;
  position: absolute;
}
</style>
<style>
#right {
  background-color: rgb(240, 243, 239);
}
.right_top {
  font-size: 12px;
  width: 100%;
  background-color: #fff;
  padding: 0px 20px 0px;
  margin-bottom: 20px;
  line-height: 58px;
}
#myOrder .right_bottom {
  width: 100%;
  background-color: #fff;
  height: 800px;
}
#myOrder .el-tabs__nav-scroll {
  margin-left: 20px;
  font-size: 12px;
}
#myOrder .is-active {
  color: #df3028;
}
#myOrder .el-tabs__active-bar {
  background-color: #df3028;
}
#myOrder .el-tabs__item {
  font-size: 12px;
}
#myOrder .tb {
  font-size: 12px;
  color: #aaa;
  margin-top: 20px;
  text-align: center;
  overflow: hidden;
  border-collapse: collapse;
  text-indent: initial;
  border-spacing: 2px;
  border: silver 1px solid;
  -webkit-font-smoothing: antialiased;
}
#myOrder .th {
  background-color: #f5f5f5;
  line-height: 31px;
  padding: 2px 0 0;
  height: 31px;
  border: 0;
  margin-right: 30px;
  display: block;
  margin-left: 10px;
  float: left;
}
#myOrder .td {
  display: inline-block;
  border: 0;
  background-color: #fff;
  margin-right: 30px;
}
#myOrder .td button {
  font-size: 12px;
}
#myOrder .tr {
  background-color: #fff;
}
.colorth {
  background-color: #f5f5f5;
}

.black {
  color: #333;
}
td,
tr {
  overflow: hidden;
}
#myOrder .title {
  width: 260px;
  overflow: hidden;
}
</style>